package by.dkusch.aircompany.webapp.page.users;

import javax.inject.Inject;

import org.apache.wicket.model.IModel;
import org.apache.wicket.model.ResourceModel;

import by.dkusch.aircompany.services.UserService;
import by.dkusch.aircompany.webapp.app.BasicAuthenticationSession;
import by.dkusch.aircompany.webapp.page.base.BaseListLayout;
import by.dkusch.aircompany.webapp.page.base.enums.ActionType;
import by.dkusch.aircompany.webapp.page.users.panel.ProfileEditPanel;
import by.dkusch.aircompany.webapp.page.users.panel.ProfileListPanel;

public class UserProfilePage extends BaseListLayout {

	/**
	 * 
	 */
	@Inject
	UserService userService;

	private static final long serialVersionUID = 1L;

	@Override
	protected IModel<String> getPageTitle() {
		return new ResourceModel("p.userprofile.title");
	}

	@Override
	protected void onInitialize() {
		super.onInitialize();
		if (BasicAuthenticationSession.get().isUserDba()) {
			add(new ProfileListPanel("panel-list", getItemsPerPage()));
		} else {
			add(new ProfileEditPanel("panel-list", userService.getByIdWithLazyDetails(BasicAuthenticationSession.get().getUser().getId()), null, ActionType.EDIT));
		}

	};
}
